home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / dec8.c < prev    next >
C/C++ Source or Header  |  2000-04-23  |  24KB  |  843 lines

  1. /***************************************************************************
  2.  
  3. Cobra Command:
  4.   2 BAC06 background generator chips, same as Dec0.
  5.   1 MXC06 chip for sprites, same as Dec0.
  6.   256 colours, palette generated by ram.
  7.  
  8. The Real Ghostbusters:
  9. 1 Deco VSC30 (M60348)
  10. 1 Deco HMC20 (M60232)
  11.  
  12.   1 playfield, same as above, with rowscroll
  13.   1024 colours from 2 proms.
  14.   Sprite hardware close to above, there are some unused (unknown) bits per sprite.
  15.  
  16. Super Real Darwin:
  17.   1 playfield, x-scroll only
  18.   Closer to earlier Darwin 4078 board than above games.
  19.  
  20. Last Mission/Shackled:
  21.     Has 1 Deco VSC30 (M60348) (From readme file)
  22.     Has 1 Deco HMC20 (M60232) (From readme file)
  23.  
  24.     1 playfield
  25.     Sprite hardware same as Karnov.
  26.     (Shackled) Palettes 8-15 for tiles seem to have priority over sprites.
  27.  
  28. Gondomania:
  29.     Has two large square surface mount chips: [ DRL 40, 8053, 8649a ]
  30.     Has 1 Deco VSC30 (M60348)
  31.     Has 1 Deco HMC20 (M60232)
  32.     Priority - all tiles with *pens* 8-15 appear over sprites with palettes 8-15.
  33.  
  34. Oscar:
  35.     Uses MXC-06 custom chip for sprites.
  36.     Uses BAC-06 custom chip for background.
  37.     I can't find what makes the fix chars...
  38.     Priority - tiles with palettes 8-15 have their *pens* 8-15 appearing over
  39. sprites.
  40.  
  41. ***************************************************************************/
  42.  
  43. #include "driver.h"
  44. #include "vidhrdw/generic.h"
  45.  
  46. static int scroll1[4],scroll2[4];
  47. static struct tilemap *dec8_pf0_tilemap,*dec8_pf1_tilemap,*dec8_fix_tilemap;
  48. static int dec8_pf0_control[0x20],dec8_pf1_control[0x20];
  49. static int gfx_bank,gfx_mask,game_uses_priority,flipscreen;
  50. static unsigned char *gfx_base;
  51. unsigned char *dec8_pf0_data,*dec8_pf1_data,*dec8_row;
  52.  
  53. /***************************************************************************
  54.  
  55.   Convert the color PROMs into a more useable format.
  56.  
  57.   Real Ghostbusters has two 1024x8 palette PROM.
  58.   I don't know the exact values of the resistors between the RAM and the
  59.   RGB output. I assumed these values (the same as Commando)
  60.  
  61.   bit 7 -- 220 ohm resistor  -- GREEN
  62.         -- 470 ohm resistor  -- GREEN
  63.         -- 1  kohm resistor  -- GREEN
  64.         -- 2.2kohm resistor  -- GREEN
  65.         -- 220 ohm resistor  -- RED
  66.         -- 470 ohm resistor  -- RED
  67.         -- 1  kohm resistor  -- RED
  68.   bit 0 -- 2.2kohm resistor  -- RED
  69.  
  70.   bit 7 -- unused
  71.         -- unused
  72.         -- unused
  73.         -- unused
  74.         -- 220 ohm resistor  -- BLUE
  75.         -- 470 ohm resistor  -- BLUE
  76.         -- 1  kohm resistor  -- BLUE
  77.   bit 0 -- 2.2kohm resistor  -- BLUE
  78.  
  79. ***************************************************************************/
  80. void ghostb_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom)
  81. {
  82.     int i;
  83.  
  84.     for (i = 0;i < Machine->drv->total_colors;i++)
  85.     {
  86.         int bit0,bit1,bit2,bit3;
  87.  
  88.         bit0 = (color_prom[0] >> 0) & 0x01;
  89.         bit1 = (color_prom[0] >> 1) & 0x01;
  90.         bit2 = (color_prom[0] >> 2) & 0x01;
  91.         bit3 = (color_prom[0] >> 3) & 0x01;
  92.         *(palette++) = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
  93.         bit0 = (color_prom[0] >> 4) & 0x01;
  94.         bit1 = (color_prom[0] >> 5) & 0x01;
  95.         bit2 = (color_prom[0] >> 6) & 0x01;
  96.         bit3 = (color_prom[0] >> 7) & 0x01;
  97.         *(palette++) = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
  98.         bit0 = (color_prom[Machine->drv->total_colors] >> 0) & 0x01;
  99.         bit1 = (color_prom[Machine->drv->total_colors] >> 1) & 0x01;
  100.         bit2 = (color_prom[Machine->drv->total_colors] >> 2) & 0x01;
  101.         bit3 = (color_prom[Machine->drv->total_colors] >> 3) & 0x01;
  102.         *(palette++) = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
  103.  
  104.         color_prom++;
  105.     }
  106. }
  107.  
  108. WRITE_HANDLER( dec8_flipscreen_w )
  109. {
  110.     flipscreen=data;
  111.     tilemap_set_flip(ALL_TILEMAPS,flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
  112. }
  113.  
  114. WRITE_HANDLER( dec8_bac06_0_w )
  115. {
  116.     dec8_pf0_control[offset]=data;
  117. }
  118.  
  119. WRITE_HANDLER( dec8_bac06_1_w )
  120. {
  121.     dec8_pf1_control[offset]=data;
  122. }
  123.  
  124. WRITE_HANDLER( dec8_pf0_data_w )
  125. {
  126.     dec8_pf0_data[offset]=data;
  127.     tilemap_mark_tile_dirty(dec8_pf0_tilemap,offset/2);
  128. }
  129.  
  130. WRITE_HANDLER( dec8_pf1_data_w )
  131. {
  132.     dec8_pf1_data[offset]=data;
  133.     tilemap_mark_tile_dirty(dec8_pf1_tilemap,offset/2);
  134. }
  135.  
  136. READ_HANDLER( dec8_pf0_data_r )
  137. {
  138.     return dec8_pf0_data[offset];
  139. }
  140.  
  141. READ_HANDLER( dec8_pf1_data_r )
  142. {
  143.     return dec8_pf1_data[offset];
  144. }
  145.  
  146. WRITE_HANDLER( dec8_videoram_w )
  147. {
  148.     videoram[offset]=data;
  149.     tilemap_mark_tile_dirty( dec8_fix_tilemap,offset/2 );
  150. }
  151.  
  152. WRITE_HANDLER( srdarwin_videoram_w )
  153. {
  154.     videoram[offset]=data;
  155.     tilemap_mark_tile_dirty( dec8_fix_tilemap,offset );
  156. }
  157.  
  158. WRITE_HANDLER( dec8_scroll1_w )
  159. {
  160.     scroll1[offset]=data;
  161. }
  162.  
  163. WRITE_HANDLER( dec8_scroll2_w )
  164. {
  165.     scroll2[offset]=data;
  166. }
  167.  
  168. WRITE_HANDLER( srdarwin_control_w )
  169. {
  170.     int bankaddress;
  171.     unsigned char *RAM = memory_region(REGION_CPU1);
  172.  
  173.     switch (offset) {
  174.         case 0: /* Top 3 bits - bank switch, bottom 4 - scroll MSB */
  175.             bankaddress = 0x10000 + (data >> 5) * 0x4000;
  176.             cpu_setbank(1,&RAM[bankaddress]);
  177.             scroll2[0]=data&0xf;
  178.             return;
  179.  
  180.         case 1:
  181.             scroll2[1]=data;
  182.             return;
  183.     }
  184. }
  185.  
  186. WRITE_HANDLER( lastmiss_control_w )
  187. {
  188.     int bankaddress;
  189.     unsigned char *RAM = memory_region(REGION_CPU1);
  190.  
  191.     /* Bottom 4 bits - bank switch, Bits 4 & 5 - Scroll MSBs */
  192.     bankaddress = 0x10000 + (data & 0x0f) * 0x4000;
  193.     cpu_setbank(1,&RAM[bankaddress]);
  194.  
  195.     scroll2[0]=(data>>5)&1;
  196.     scroll2[2]=(data>>6)&1;
  197.  
  198. if (cpu_get_pc()==0xfa51) cpu_set_reset_line(1,PULSE_LINE); /* No way this can be right... */
  199. if (cpu_get_pc()==0xf9d2) cpu_set_reset_line(1,PULSE_LINE); /* No way this can be right... */
  200.  
  201. //logerror("PC %06x - Write %02x to %04x\n",cpu_get_pc(),data,offset+0x1802);
  202. }
  203.  
  204. WRITE_HANDLER( lastmiss_scrollx_w )
  205. {
  206.     scroll2[1]=data;
  207. }
  208.  
  209. WRITE_HANDLER( lastmiss_scrolly_w )
  210. {
  211.     scroll2[3]=data;
  212. }
  213.  
  214. WRITE_HANDLER( gondo_scroll_w )
  215. {
  216.     switch (offset) {
  217.         case 0x0:
  218.             scroll2[1]=data; /* X LSB */
  219.             break;
  220.         case 0x8:
  221.             scroll2[3]=data; /* Y LSB */
  222.             break;
  223.         case 0x10:
  224.             scroll2[0]=(data>>0)&1; /* Bit 0: X MSB */
  225.             scroll2[2]=(data>>1)&1; /* Bit 1: Y MSB */
  226.             /* Bit 2 is also used in Gondo & Garyoret */
  227.             break;
  228.     }
  229. }
  230.  
  231. /******************************************************************************/
  232.  
  233. /* 'Karnov' sprites, used by Gondomania, Last Mission, Shackled, Ghostbusters */
  234. static void draw_sprites1(struct osd_bitmap *bitmap, int priority)
  235. {
  236.     int offs,x,y,sprite,sprite2,colour,extra,fx,fy;
  237.  
  238.     for (offs = 0;offs < 0x800;offs += 8)
  239.     {
  240.         y=buffered_spriteram[offs+1]+(buffered_spriteram[offs]<<8);
  241.         if ((y&0x8000) == 0) continue;
  242.  
  243.         fx=buffered_spriteram[offs+3];
  244.  
  245.         if ((fx&0x1) == 0) continue;
  246.  
  247.         extra=fx&0x10;
  248.         fy=fx&0x2;
  249.         fx=fx&0x4;
  250.  
  251.         x = buffered_spriteram[offs+5]+(buffered_spriteram[offs+4]<<8);
  252.         colour = buffered_spriteram[offs+6] >> 4;
  253.         if (priority==1 && (colour&8)) continue;
  254.         if (priority==2 && !(colour&8)) continue;
  255.         sprite = buffered_spriteram[offs+7]+(buffered_spriteram[offs+6]<<8);
  256.         sprite &= 0x0fff;
  257.  
  258.         if (extra) {y=y+16;sprite&=0xffe;}
  259.  
  260.         x = x & 0x01ff;
  261.         y = y & 0x01ff;
  262.         x=(x+16)%0x200;
  263.         y=(y+16)%0x200;
  264.         x=256 - x;
  265.         y=256 - y;
  266.         if (flipscreen) {
  267.             y=240-y;
  268.             x=240-x;
  269.             if (fx) fx=0; else fx=1;
  270.             if (fy) fy=0; else fy=1;
  271.             if (extra) y=y-16;
  272.         }
  273.  
  274.         /* Y Flip determines order of multi-sprite */
  275.         if (extra && fy) {
  276.             sprite2=sprite;
  277.             sprite++;
  278.         }
  279.         else
  280.             sprite2=sprite+1;
  281.  
  282.         drawgfx(bitmap,Machine->gfx[1],
  283.                 sprite,
  284.                 colour,fx,fy,x,y,
  285.                 0,TRANSPARENCY_PEN,0);
  286.  
  287.         /* 1 more sprite drawn underneath */
  288.         if (extra)
  289.             drawgfx(bitmap,Machine->gfx[1],
  290.                 sprite2,
  291.                 colour,fx,fy,x,y+16,
  292.                 0,TRANSPARENCY_PEN,0);
  293.     }
  294. }
  295.  
  296. /* 'Dec0' sprites, used by Cobra Command, Oscar */
  297. static void draw_sprites2(struct osd_bitmap *bitmap, int priority)
  298. {
  299.     int offs,x,y,sprite,colour,multi,fx,fy,inc,flash,mult;
  300.  
  301.     /* Sprites */
  302.     for (offs = 0;offs < 0x800;offs += 8)
  303.     {
  304.         y =buffered_spriteram[offs+1]+(buffered_spriteram[offs]<<8);
  305.          if ((y&0x8000) == 0) continue;
  306.         x = buffered_spriteram[offs+5]+(buffered_spriteram[offs+4]<<8);
  307.         colour = ((x & 0xf000) >> 12);
  308.         flash=x&0x800;
  309.         if (flash && (cpu_getcurrentframe() & 1)) continue;
  310.  
  311.         if (priority==1 &&  (colour&4)) continue;
  312.         if (priority==2 && !(colour&4)) continue;
  313.  
  314.         fx = y & 0x2000;
  315.         fy = y & 0x4000;
  316.         multi = (1 << ((y & 0x1800) >> 11)) - 1;    /* 1x, 2x, 4x, 8x height */
  317.  
  318.                                             /* multi = 0   1   3   7 */
  319.         sprite = buffered_spriteram[offs+3]+(buffered_spriteram[offs+2]<<8);
  320.         sprite &= 0x0fff;
  321.  
  322.         x = x & 0x01ff;
  323.         y = y & 0x01ff;
  324.         if (x >= 256) x -= 512;
  325.         if (y >= 256) y -= 512;
  326.         x = 240 - x;
  327.         y = 240 - y;
  328.  
  329.         sprite &= ~multi;
  330.         if (fy)
  331.             inc = -1;
  332.         else
  333.         {
  334.             sprite += multi;
  335.             inc = 1;
  336.         }
  337.  
  338.         if (flipscreen) {
  339.             y=240-y;
  340.             x=240-x;
  341.             if (fx) fx=0; else fx=1;
  342.             if (fy) fy=0; else fy=1;
  343.             mult=16;
  344.         }
  345.         else mult=-16;
  346.  
  347.         while (multi >= 0)
  348.         {
  349.             drawgfx(bitmap,Machine->gfx[1],
  350.                     sprite - multi * inc,
  351.                     colour,
  352.                     fx,fy,
  353.                     x,y + mult * multi,
  354.                     &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  355.             multi--;
  356.         }
  357.     }
  358. }
  359.  
  360. static void srdarwin_drawsprites(struct osd_bitmap *bitmap, int pri)
  361. {
  362.     int offs;
  363.  
  364.     /* Sprites */
  365.     for (offs = 0;offs < 0x200;offs += 4)
  366.     {
  367.         int multi,fx,sx,sy,sy2,code,color;
  368.  
  369.         code = buffered_spriteram[offs+3] + ( ( buffered_spriteram[offs+1] & 0xe0 ) << 3 );
  370.         sx = (241 - buffered_spriteram[offs+2]);
  371.     //if (sx < -7) sx += 256;
  372.  
  373.         sy = buffered_spriteram[offs];
  374.         color = (buffered_spriteram[offs+1] & 0x03) + ((buffered_spriteram[offs+1] & 0x08) >> 1);
  375.  
  376.         if (pri==0 && color!=0) continue;
  377.         if (pri==1 && color==0) continue;
  378.  
  379.         fx = buffered_spriteram[offs+1] & 0x04;
  380.         multi = buffered_spriteram[offs+1] & 0x10;
  381.  
  382.         if (flipscreen) {
  383.             sy=240-sy;
  384.             sx=240-sx;
  385.             if (fx) fx=0; else fx=1;
  386.             sy2=sy-16;
  387.         }
  388.         else sy2=sy+16;
  389.  
  390.         drawgfx(bitmap,Machine->gfx[1],
  391.                 code,
  392.                 color,
  393.                 fx,flipscreen,
  394.                 sx,sy,
  395.                 &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  396.         if (multi)
  397.             drawgfx(bitmap,Machine->gfx[1],
  398.                 code+1,
  399.                 color,
  400.                 fx,flipscreen,
  401.                 sx,sy2,
  402.                 &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  403.     }
  404. }
  405.  
  406. /* Draw character tiles, each game has different colour masks */
  407. static void draw_characters(struct osd_bitmap *bitmap, int mask, int shift)
  408. {
  409.     int mx,my,tile,color,offs;
  410.  
  411.     for (offs = 0x800 - 2;offs >= 0;offs -= 2) {
  412.         tile=videoram[offs+1]+((videoram[offs]&0xf)<<8);
  413.  
  414.         if (!tile) continue;
  415.  
  416.         color=(videoram[offs]&mask)>>shift;
  417.         mx = (offs/2) % 32;
  418.         my = (offs/2) / 32;
  419.  
  420.         drawgfx(bitmap,Machine->gfx[0],
  421.                 tile,color,0,0,8*mx,8*my,
  422.                 &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  423.     }
  424. }
  425.  
  426. /******************************************************************************/
  427.  
  428. void cobracom_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
  429. {
  430.     tilemap_set_scrollx( dec8_pf0_tilemap,0, (dec8_pf0_control[0x10]<<8)+dec8_pf0_control[0x11] );
  431.     tilemap_set_scrolly( dec8_pf0_tilemap,0, (dec8_pf0_control[0x12]<<8)+dec8_pf0_control[0x13] );
  432.     tilemap_set_scrollx( dec8_pf1_tilemap,0, (dec8_pf1_control[0x10]<<8)+dec8_pf1_control[0x11] );
  433.     tilemap_set_scrolly( dec8_pf1_tilemap,0, (dec8_pf1_control[0x12]<<8)+dec8_pf1_control[0x13] );
  434.     dec8_flipscreen_w(0,dec8_pf0_control[0]>>7);
  435.  
  436.     gfx_mask=3;
  437.     gfx_bank=3;
  438.     gfx_base=dec8_pf0_data;
  439.     tilemap_update(dec8_pf0_tilemap);
  440.  
  441.     gfx_bank=2;
  442.     gfx_base=dec8_pf1_data;
  443.     tilemap_update(dec8_pf1_tilemap);
  444.     tilemap_update(dec8_fix_tilemap);
  445.  
  446.     if (palette_recalc())
  447.         tilemap_mark_all_pixels_dirty(ALL_TILEMAPS);
  448.     tilemap_render(ALL_TILEMAPS);
  449.  
  450.     tilemap_draw(bitmap,dec8_pf0_tilemap,0);
  451.     draw_sprites2(bitmap,1);
  452.     tilemap_draw(bitmap,dec8_pf1_tilemap,0);
  453.     draw_sprites2(bitmap,2);
  454.     tilemap_draw(bitmap,dec8_fix_tilemap,0);
  455. }
  456.  
  457. /******************************************************************************/
  458.  
  459. static void get_bac0_tile_info( int tile_index )
  460. {
  461.     int tile,color,offs=tile_index<<1;
  462.  
  463.     tile=(gfx_base[offs]<<8) | gfx_base[offs+1];
  464.     color=tile >> 12;
  465.     if (color>7 && game_uses_priority) tile_info.priority=1; else tile_info.priority=0;
  466.  
  467.     SET_TILE_INFO(gfx_bank,tile&0xfff,color&gfx_mask)
  468. }
  469.  
  470. static UINT32 bac0_scan_rows(UINT32 col,UINT32 row,UINT32 num_cols,UINT32 num_rows)
  471. {
  472.     /* logical (col,row) -> memory offset */
  473.     return ((col & 0x0f) + ((row & 0x0f) << 4)) + ((col & 0x10) << 5) + ((row & 0x10) << 4);
  474. }
  475.  
  476. static void get_cobracom_fix_tile_info( int tile_index )
  477. {
  478.     int offs=tile_index<<1;
  479.     int tile=videoram[offs+1]+(videoram[offs]<<8);
  480.     int color=(tile&0xe000) >> 13;
  481.  
  482.     SET_TILE_INFO(0,tile&0xfff,color)
  483. }
  484.  
  485. int cobracom_vh_start(void)
  486. {
  487.     game_uses_priority=0;
  488.     dec8_pf0_tilemap = tilemap_create(get_bac0_tile_info,bac0_scan_rows,0,16,16,32,32);
  489.     dec8_pf1_tilemap = tilemap_create(get_bac0_tile_info,bac0_scan_rows,TILEMAP_TRANSPARENT,16,16,32,32);
  490.     dec8_fix_tilemap = tilemap_create(get_cobracom_fix_tile_info,tilemap_scan_rows,TILEMAP_TRANSPARENT,8,8,32,32);
  491.  
  492.     if (!dec8_pf0_tilemap || !dec8_pf1_tilemap || !dec8_fix_tilemap)
  493.         return 1;
  494.  
  495.     dec8_pf1_tilemap->transparent_pen = 0;
  496.     dec8_fix_tilemap->transparent_pen = 0;
  497.  
  498.     return 0;
  499. }
  500.  
  501. /******************************************************************************/
  502.  
  503. void ghostb_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
  504. {
  505.    if (dec8_pf0_control[0]&0x4) { /* Rowscroll */
  506.          int offs;
  507.  
  508.         tilemap_set_scroll_rows(dec8_pf0_tilemap,512);
  509.         for (offs = 0;offs < 512;offs+=2)
  510.             tilemap_set_scrollx( dec8_pf0_tilemap,offs/2, (dec8_pf0_control[0x10]<<8)+dec8_pf0_control[0x11] + (dec8_row[offs]<<8)+dec8_row[offs+1] );
  511.     } else {
  512.         tilemap_set_scroll_rows(dec8_pf0_tilemap,1);
  513.         tilemap_set_scrollx( dec8_pf0_tilemap,0, (dec8_pf0_control[0x10]<<8)+dec8_pf0_control[0x11] );
  514.     }
  515.     tilemap_set_scrolly( dec8_pf0_tilemap,0, (dec8_pf0_control[0x12]<<8)+dec8_pf0_control[0x13] );
  516.  
  517.     tilemap_update(ALL_TILEMAPS);
  518.     if (palette_recalc())
  519.         tilemap_mark_all_pixels_dirty(ALL_TILEMAPS);
  520.     tilemap_render(ALL_TILEMAPS);
  521.  
  522.     tilemap_draw(bitmap,dec8_pf0_tilemap,0);
  523.     draw_sprites1(bitmap,0);
  524.     tilemap_draw(bitmap,dec8_fix_tilemap,0);
  525. }
  526.  
  527. static void get_ghostb_fix_tile_info( int tile_index )
  528. {
  529.     int offs=tile_index<<1;
  530.     int tile=videoram[offs+1]+(videoram[offs]<<8);
  531.     int color=(tile&0xc00) >> 10;
  532.  
  533.     SET_TILE_INFO(0,tile&0x3ff,color)
  534. }
  535.  
  536. int ghostb_vh_start(void)
  537. {
  538.     dec8_pf0_tilemap = tilemap_create(get_bac0_tile_info,bac0_scan_rows,0,16,16,32,32);
  539.     dec8_fix_tilemap = tilemap_create(get_ghostb_fix_tile_info,tilemap_scan_rows,TILEMAP_TRANSPARENT,8,8,32,32);
  540.     dec8_fix_tilemap->transparent_pen = 0;
  541.  
  542.     if (!dec8_pf0_tilemap || !dec8_fix_tilemap)
  543.         return 1;
  544.  
  545.     gfx_bank=2;
  546.     gfx_mask=0xf;
  547.     gfx_base=dec8_pf0_data;
  548.  
  549.     return 0;
  550. }
  551.  
  552. /******************************************************************************/
  553.  
  554. void oscar_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
  555. {
  556.     tilemap_set_scrollx( dec8_pf0_tilemap,0, (dec8_pf0_control[0x10]<<8)+dec8_pf0_control[0x11] );
  557.     tilemap_set_scrolly( dec8_pf0_tilemap,0, (dec8_pf0_control[0x12]<<8)+dec8_pf0_control[0x13] );
  558.     dec8_flipscreen_w(0,dec8_pf0_control[1]>>7);
  559.  
  560.     tilemap_update(ALL_TILEMAPS);
  561.     if (palette_recalc())
  562.         tilemap_mark_all_pixels_dirty(ALL_TILEMAPS);
  563.     tilemap_render(ALL_TILEMAPS);
  564.  
  565.     tilemap_draw(bitmap,dec8_pf0_tilemap,TILEMAP_BACK | 0);
  566.     tilemap_draw(bitmap,dec8_pf0_tilemap,TILEMAP_BACK | 1);
  567.     tilemap_draw(bitmap,dec8_pf0_tilemap,TILEMAP_FRONT | 0);
  568.     draw_sprites2(bitmap,0);
  569.     tilemap_draw(bitmap,dec8_pf0_tilemap,TILEMAP_FRONT | 1);
  570.     tilemap_draw(bitmap,dec8_fix_tilemap,0);
  571. }
  572.  
  573. static void get_oscar_fix_tile_info( int tile_index )
  574. {
  575.     int offs=tile_index<<1;
  576.     int tile=videoram[offs+1]+(videoram[offs]<<8);
  577.     int color=(tile&0xf000) >> 14;
  578.  
  579.     SET_TILE_INFO(0,tile&0xfff,color)
  580. }
  581.  
  582. int oscar_vh_start(void)
  583. {
  584.     dec8_pf0_tilemap = tilemap_create(get_bac0_tile_info,bac0_scan_rows,TILEMAP_SPLIT,16,16,32,32);
  585.     dec8_fix_tilemap = tilemap_create(get_oscar_fix_tile_info,tilemap_scan_rows,TILEMAP_TRANSPARENT,8,8,32,32);
  586.  
  587.     if (!dec8_pf0_tilemap || !dec8_fix_tilemap)
  588.         return 1;
  589.  
  590.     dec8_fix_tilemap->transparent_pen = 0;
  591.     dec8_pf0_tilemap->transmask[0] = 0x00ff; /* Bottom 8 pens */
  592.     dec8_pf0_tilemap->transmask[1] = 0xff00; /* Top 8 pens */
  593.     game_uses_priority=1;
  594.     gfx_bank=2;
  595.     gfx_mask=0x7;
  596.     gfx_base=dec8_pf0_data;
  597.  
  598.     return 0;
  599. }
  600.  
  601. /******************************************************************************/
  602.  
  603. void lastmiss_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
  604. {
  605.     tilemap_set_scrollx( dec8_pf0_tilemap,0, ((scroll2[0]<<8)+scroll2[1]) );
  606.     tilemap_set_scrolly( dec8_pf0_tilemap,0, ((scroll2[2]<<8)+scroll2[3]) );
  607.     tilemap_update(ALL_TILEMAPS);
  608.  
  609.     palette_init_used_colors();
  610.     memset(palette_used_colors+256,PALETTE_COLOR_USED,256);
  611.     if (palette_recalc())
  612.         tilemap_mark_all_pixels_dirty(ALL_TILEMAPS);
  613.     tilemap_render(ALL_TILEMAPS);
  614.  
  615.     tilemap_draw(bitmap,dec8_pf0_tilemap,0);
  616.     draw_sprites1(bitmap,0);
  617.     tilemap_draw(bitmap,dec8_fix_tilemap,0);
  618. }
  619.  
  620. void shackled_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
  621. {
  622.     tilemap_set_scrollx( dec8_pf0_tilemap,0, ((scroll2[0]<<8)+scroll2[1]) );
  623.     tilemap_set_scrolly( dec8_pf0_tilemap,0, ((scroll2[2]<<8)+scroll2[3]) );
  624.     tilemap_update(ALL_TILEMAPS);
  625.  
  626.     palette_init_used_colors();
  627.     memset(palette_used_colors+256,PALETTE_COLOR_USED,256);
  628.     if (palette_recalc())
  629.         tilemap_mark_all_pixels_dirty(ALL_TILEMAPS);
  630.     tilemap_render(ALL_TILEMAPS);
  631.  
  632.     tilemap_draw(bitmap,dec8_pf0_tilemap,TILEMAP_BACK | 0);
  633.     tilemap_draw(bitmap,dec8_pf0_tilemap,TILEMAP_BACK | 1);
  634.     tilemap_draw(bitmap,dec8_pf0_tilemap,TILEMAP_FRONT | 0);
  635.     draw_sprites1(bitmap,0);
  636.     tilemap_draw(bitmap,dec8_pf0_tilemap,TILEMAP_FRONT | 1);
  637.     tilemap_draw(bitmap,dec8_fix_tilemap,0);
  638. }
  639.  
  640. static UINT32 lastmiss_scan_rows(UINT32 col,UINT32 row,UINT32 num_cols,UINT32 num_rows)
  641. {
  642.     /* logical (col,row) -> memory offset */
  643.     return ((col & 0x0f) + ((row & 0x0f) << 4)) + ((col & 0x10) << 4) + ((row & 0x10) << 5);
  644. }
  645.  
  646. static void get_lastmiss_tile_info( int tile_index )
  647. {
  648.     int offs=tile_index*2;
  649.     int tile=dec8_pf0_data[offs+1]+(dec8_pf0_data[offs]<<8);
  650.     int color=tile >> 12;
  651.  
  652.     if (color>7 && game_uses_priority) tile_info.priority=1; else tile_info.priority=0;
  653.  
  654.     SET_TILE_INFO(2,tile&0xfff,color)
  655. }
  656.  
  657. static void get_lastmiss_fix_tile_info( int tile_index )
  658. {
  659.     int offs=tile_index<<1;
  660.     int tile=videoram[offs+1]+(videoram[offs]<<8);
  661.     int color=(tile&0xc000) >> 14;
  662.  
  663.     SET_TILE_INFO(0,tile&0xfff,color)
  664. }
  665.  
  666. int lastmiss_vh_start(void)
  667. {
  668.     dec8_pf0_tilemap = tilemap_create(get_lastmiss_tile_info,lastmiss_scan_rows,0,16,16,32,32);
  669.     dec8_fix_tilemap = tilemap_create(get_lastmiss_fix_tile_info,tilemap_scan_rows,TILEMAP_TRANSPARENT,8,8,32,32);
  670.  
  671.     if (!dec8_pf0_tilemap || !dec8_fix_tilemap)
  672.         return 1;
  673.  
  674.     dec8_fix_tilemap->transparent_pen = 0;
  675.     game_uses_priority=0;
  676.  
  677.     return 0;
  678. }
  679.  
  680. int shackled_vh_start(void)
  681. {
  682.     dec8_pf0_tilemap = tilemap_create(get_lastmiss_tile_info,lastmiss_scan_rows,TILEMAP_SPLIT,16,16,32,32);
  683.     dec8_fix_tilemap = tilemap_create(get_lastmiss_fix_tile_info,tilemap_scan_rows,TILEMAP_TRANSPARENT,8,8,32,32);
  684.  
  685.     if (!dec8_pf0_tilemap || !dec8_fix_tilemap)
  686.         return 1;
  687.  
  688.     dec8_fix_tilemap->transparent_pen = 0;
  689.     dec8_pf0_tilemap->transmask[0] = 0x000f; /* Bottom 12 pens */
  690.     dec8_pf0_tilemap->transmask[1] = 0xfff0; /* Top 4 pens */
  691.     game_uses_priority=1;
  692.  
  693.     return 0;
  694. }
  695.  
  696. /******************************************************************************/
  697.  
  698. void srdarwin_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
  699. {
  700.     tilemap_set_scrollx( dec8_pf0_tilemap,0, (scroll2[0]<<8)+scroll2[1] );
  701.     tilemap_update(ALL_TILEMAPS);
  702.  
  703.     if (palette_recalc())
  704.         tilemap_mark_all_pixels_dirty(ALL_TILEMAPS);
  705.  
  706.     tilemap_render(ALL_TILEMAPS);
  707.     tilemap_draw(bitmap,dec8_pf0_tilemap,TILEMAP_BACK | 1);
  708.     tilemap_draw(bitmap,dec8_pf0_tilemap,TILEMAP_BACK | 0);
  709.     tilemap_draw(bitmap,dec8_pf0_tilemap,TILEMAP_FRONT | 1);
  710.     srdarwin_drawsprites(bitmap,0); /* Priority may not be right on later levels */
  711.     tilemap_draw(bitmap,dec8_pf0_tilemap,TILEMAP_FRONT | 0);
  712.     srdarwin_drawsprites(bitmap,1);
  713.     tilemap_draw(bitmap,dec8_fix_tilemap,0);
  714. }
  715.  
  716. static void get_srdarwin_fix_tile_info( int tile_index )
  717. {
  718.     int tile=videoram[tile_index];
  719.     int color=0; /* ? */
  720.  
  721.     if (color>1) tile_info.priority=1; else tile_info.priority=0;
  722.  
  723.     SET_TILE_INFO(0,tile,color)
  724. }
  725.  
  726. static void get_srdarwin_tile_info(int tile_index)
  727. {
  728.     int tile=dec8_pf0_data[2*tile_index+1]+(dec8_pf0_data[2*tile_index]<<8);
  729.     int color=tile >> 12;
  730.     int bank;
  731.  
  732.     tile=tile&0xfff;
  733.     bank=(tile/0x100)+2;
  734.  
  735.     SET_TILE_INFO(bank,tile,color)
  736. }
  737.  
  738. int srdarwin_vh_start(void)
  739. {
  740.     dec8_pf0_tilemap = tilemap_create(get_srdarwin_tile_info,tilemap_scan_rows,TILEMAP_SPLIT,16,16,32,16);
  741.     dec8_fix_tilemap = tilemap_create(get_srdarwin_fix_tile_info,tilemap_scan_rows,TILEMAP_TRANSPARENT,8,8,32,32);
  742.  
  743.     if (!dec8_pf0_tilemap || !dec8_fix_tilemap)
  744.         return 1;
  745.  
  746.     dec8_fix_tilemap->transparent_pen = 0;
  747.     dec8_pf0_tilemap->transmask[0] = 0x00ff; /* Bottom 8 pens */
  748.     dec8_pf0_tilemap->transmask[1] = 0xff00; /* Top 8 pens */
  749.  
  750.     return 0;
  751. }
  752.  
  753. /******************************************************************************/
  754.  
  755. void gondo_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
  756. {
  757.     tilemap_set_scrollx( dec8_pf0_tilemap,0, ((scroll2[0]<<8)+scroll2[1]) );
  758.     tilemap_set_scrolly( dec8_pf0_tilemap,0, ((scroll2[2]<<8)+scroll2[3]) );
  759.     tilemap_update(ALL_TILEMAPS);
  760.  
  761.     palette_init_used_colors();
  762.     memset(palette_used_colors+256,PALETTE_COLOR_USED,256);
  763.     if (palette_recalc())
  764.         tilemap_mark_all_pixels_dirty(ALL_TILEMAPS);
  765.     tilemap_render(ALL_TILEMAPS);
  766.  
  767.     tilemap_draw(bitmap,dec8_pf0_tilemap,TILEMAP_BACK);
  768.     draw_sprites1(bitmap,2);
  769.     tilemap_draw(bitmap,dec8_pf0_tilemap,TILEMAP_FRONT);
  770.     draw_sprites1(bitmap,1);
  771.     tilemap_draw(bitmap,dec8_fix_tilemap,0);
  772. }
  773.  
  774. void garyoret_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
  775. {
  776.     tilemap_set_scrollx( dec8_pf0_tilemap,0, ((scroll2[0]<<8)+scroll2[1]) );
  777.     tilemap_set_scrolly( dec8_pf0_tilemap,0, ((scroll2[2]<<8)+scroll2[3]) );
  778.     tilemap_update(ALL_TILEMAPS);
  779.  
  780.     palette_init_used_colors();
  781.     memset(palette_used_colors+256,PALETTE_COLOR_USED,256);
  782.     if (palette_recalc())
  783.         tilemap_mark_all_pixels_dirty(ALL_TILEMAPS);
  784.     tilemap_render(ALL_TILEMAPS);
  785.  
  786.     tilemap_draw(bitmap,dec8_pf0_tilemap,0);
  787.     draw_sprites1(bitmap,0);
  788.     tilemap_draw(bitmap,dec8_pf0_tilemap,1);
  789.     tilemap_draw(bitmap,dec8_fix_tilemap,0);
  790. }
  791.  
  792. static void get_gondo_fix_tile_info( int tile_index )
  793. {
  794.     int offs=tile_index*2;
  795.     int tile=videoram[offs+1]+(videoram[offs]<<8);
  796.     int color=(tile&0x7000) >> 12;
  797.  
  798.     SET_TILE_INFO(0,tile&0xfff,color)
  799. }
  800.  
  801. static void get_gondo_tile_info( int tile_index )
  802. {
  803.     int offs=tile_index*2;
  804.     int tile=dec8_pf0_data[offs+1]+(dec8_pf0_data[offs]<<8);
  805.     int color=tile>> 12;
  806.  
  807.     if (color>7 && game_uses_priority) tile_info.priority=1; else tile_info.priority=0;
  808.  
  809.     SET_TILE_INFO(2,tile&0xfff,color)
  810. }
  811.  
  812. int gondo_vh_start(void)
  813. {
  814.     dec8_fix_tilemap=tilemap_create(get_gondo_fix_tile_info,tilemap_scan_rows,TILEMAP_TRANSPARENT,8,8,32,32);
  815.     dec8_pf0_tilemap=tilemap_create(get_gondo_tile_info,tilemap_scan_rows,TILEMAP_SPLIT,16,16,32,32);
  816.  
  817.     if (!dec8_fix_tilemap || !dec8_pf0_tilemap)
  818.         return 1;
  819.  
  820.     dec8_fix_tilemap->transparent_pen = 0;
  821.     dec8_pf0_tilemap->transmask[0] = 0x00ff; /* Bottom 8 pens */
  822.     dec8_pf0_tilemap->transmask[1] = 0xff00; /* Top 8 pens */
  823.     game_uses_priority=0;
  824.  
  825.     return 0;
  826. }
  827.  
  828. int garyoret_vh_start(void)
  829. {
  830.     dec8_fix_tilemap=tilemap_create(get_gondo_fix_tile_info,tilemap_scan_rows,TILEMAP_TRANSPARENT,8,8,32,32);
  831.     dec8_pf0_tilemap=tilemap_create(get_gondo_tile_info,tilemap_scan_rows,TILEMAP_SPLIT,16,16,32,32);
  832.  
  833.     if (!dec8_fix_tilemap || !dec8_pf0_tilemap)
  834.         return 1;
  835.  
  836.     dec8_fix_tilemap->transparent_pen = 0;
  837.     game_uses_priority=1;
  838.  
  839.     return 0;
  840. }
  841.  
  842. /******************************************************************************/
  843.